pub fn mul_add(nums: &[f64]) -> f64 {
    nums.iter().fold(0.0, |acc, v| acc + *v)
}

/// 获取两个点之间的距离
pub fn get_two_ponit_distance(p1: [f64; 2], p2: [f64; 2]) -> f64 {
    let minus_x = p1[0] - p2[0];
    let minus_y = p1[1] - p2[1];
    (minus_x.powi(2) + minus_y.powi(2)).sqrt()
}

pub fn get_polyline_length(points: &[[f64; 2]]) -> f64 {
    let line_segments = (0..points.len() - 1)
        .into_iter()
        .map(|i| (points[i], points[i + 1]));
    let lengths = line_segments
        .map(|v| get_two_ponit_distance(v.0, v.1))
        .collect::<Vec<_>>();
    mul_add(&lengths)
}
